//
//  MineViewController.swift
//  手账
//
//  Created by zhuxiaoxiang on 2018/12/24.
//  Copyright © 2018年 zhuxiaoxiang. All rights reserved.
//

import UIKit

class MineViewController: BaseViewController {

    fileprivate var arr = ["关于我们", "当前版本"]
    
    fileprivate lazy var mineHeaderView: MineHeaderView = {
       let one = MineHeaderView(frame: CGRect(x: 0, y: 0, width: kScreenW, height: 150))
        return one
    }()
    
    fileprivate lazy var tableView: UITableView = {
       let one = UITableView(frame: self.view.bounds, style: UITableViewStyle.plain)
        one.delegate = self
        one.dataSource = self
        one.register(UINib(nibName: "MineTableViewCell", bundle: nil), forCellReuseIdentifier: "CELL")
        one.separatorStyle = .none
        one.rowHeight = 52
        one.tableHeaderView = self.mineHeaderView
        return one
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.addSubview(self.tableView)
    }

}

extension MineViewController: UITableViewDelegate, UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 2
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "CELL", for: indexPath) as! MineTableViewCell
        cell.accessoryType = .disclosureIndicator
        cell.textLB.text = arr[indexPath.row]
        cell.selectionStyle = .none
        return cell
    }
}

class MineHeaderView: UIView {
    
    fileprivate lazy var imageView: UIImageView = {
       let one = UIImageView(frame: CGRect(x: 0, y: 0, width: 60, height: 60))
        one.center = self.center
        one.backgroundColor = UIColor.yellow
        return one
    }()
    
    fileprivate lazy var nameLB: UILabel = {
       let one = UILabel(frame: CGRect(x: 0, y: 0, width: 120, height: 25))
        one.textAlignment = .center
        one.center = self.center
        one.text = "17621354632"
        one.font = UIFont.init(name: "PingFangSC-Regular", size: 14)
        one.textColor = UIColor.hex(hexString: "999999")
        return one
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.addSubview(self.imageView)
        self.addSubview(self.nameLB)
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        var nameLBRect = self.nameLB.frame
        nameLBRect.origin.y += 60
        self.nameLB.frame = nameLBRect
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}


